#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int is_leap_year(int n)
{
	return (n % 400 == 0) || ((n % 4 == 0) && (n % 100 != 0));
}

int main()
{
	int year = 0;
	int month = 0;
	int day = 0;
	int all = 0;
	scanf("%d %d %d", &year, &month, &day);
	int i = 1;
	for (; i < month; i++)
	{
		if (i == 4 || i == 6 || i == 9 || i == 11)
			day += 30;
		else if (i == 2)
		{
			if (is_leap_year(year))
				day += 29;
			else
				day += 28;
		}
		else
			day += 31;
	}
	printf("%d", day);
	return 0;
}